
package creature;

import toxi.physics2d.VerletParticle2D;
import toxi.physics2d.VerletSpring2D;

public class OscillatingVerletSpring2D extends VerletSpring2D
{
	public Oscillator	osc;

	public float		baseLength;
	public float		oscStrength;

	public OscillatingVerletSpring2D(VerletParticle2D a, VerletParticle2D b, float len, float str, Oscillator _osc, float _oscStrength)
	{
		super(a, b, len, str);
		baseLength = restLength;
		osc = _osc;
		oscStrength = _oscStrength;
	}
	
	public void setBaseLength(float _baseLength)
	{
		baseLength = _baseLength;
	}
	
	public float getBaseLength()
	{
		return baseLength;
	}
	
	public void setOscStrength(float _oscStrength)
	{
		oscStrength = _oscStrength;
	}

	protected void update(boolean applyConstraints)
	{
		osc.update();
		restLength = baseLength + (osc.value * baseLength * oscStrength);
		super.update(applyConstraints);
	}
}
